package rs.ac.bg.etf.estudent.fragment;

import java.util.ArrayList;
import java.util.HashMap;

import rs.ac.bg.etf.estudent.R;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ListView;
import android.widget.SimpleAdapter;

public class SchShipAndPaymentFragment extends Fragment {
	
	private ListView mSchoolarshipList, mPaymentList, mAccountList;
	private View mSchoolarshipView, mPaymentView, mAccountView;
	private SimpleAdapter mScholarshipAdapter, mPaymentAdapter, mAccountAdapter;
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		View view = inflater.inflate(R.layout.fragment_schship_and_payment, container, false);
		mSchoolarshipList = (ListView)view.findViewById(R.id.schoolarship_table);
		mSchoolarshipView = view.findViewById(R.id.schoolarship_container);
		View schshipHeaderView = inflater.inflate(R.layout.schshp_list_header, null, false);
		mSchoolarshipList.addHeaderView(schshipHeaderView);
		
		mPaymentList = (ListView)view.findViewById(R.id.payment_table);
		mPaymentView = view.findViewById(R.id.payment_container);
		View paymentHeaderView = inflater.inflate(R.layout.payment_list_header, null, false);
		mPaymentList.addHeaderView(paymentHeaderView);
		
		mAccountList = (ListView)view.findViewById(R.id.account_table);
		mAccountView = view.findViewById(R.id.account_container);
		View accountHeaderView = inflater.inflate(R.layout.account_list_header, null, false);
		mAccountList.addHeaderView(accountHeaderView);
		
		Button schspButton = (Button)view.findViewById(R.id.schollarship_button);
		schspButton.setOnClickListener(new Button.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				mSchoolarshipView.setVisibility(View.VISIBLE);
				mPaymentView.setVisibility(View.GONE);
				mAccountView.setVisibility(View.GONE);
			}
		});
		
		Button payButton = (Button)view.findViewById(R.id.payment_button);
		payButton.setOnClickListener(new Button.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				mSchoolarshipView.setVisibility(View.GONE);
				mPaymentView.setVisibility(View.VISIBLE);
				mAccountView.setVisibility(View.GONE);
			}
		});
		
		Button accButton = (Button)view.findViewById(R.id.accaunt_button);
		accButton.setOnClickListener(new Button.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				mSchoolarshipView.setVisibility(View.GONE);
				mPaymentView.setVisibility(View.GONE);
				mAccountView.setVisibility(View.VISIBLE);
			}
		});
		return view;
	}
	
	@Override
	public void onStart() {
		// TODO Auto-generated method stub
		super.onStart();
		ArrayList<HashMap<String, String>> myPaylist = new ArrayList<HashMap<String, String>>();
		HashMap<String, String> map = new HashMap<String, String>();
		map.put("datum", "1.1.2013");
		map.put("iznos", "33000");
		map.put("spec","Rata za skolarinu");
		
		
		myPaylist.add(map);
		// ...
		mPaymentAdapter = new SimpleAdapter(getActivity(), myPaylist, R.layout.payment_list_item,
		            new String[] {"datum","iznos","spec"}, new int[] {R.id.payment_date, R.id.payment_amount,R.id.payment_specification});
		mPaymentList.setAdapter(mPaymentAdapter);
		
		ArrayList<HashMap<String, String>> mySchList = new ArrayList<HashMap<String, String>>();
				
		map.put("skgod","2013/14");
		map.put("god", "druga");
		map.put("status", "samofinansirajuci");
		map.put("nacin", "standardno");
		map.put("profil","Racunarska tehnika i informatika");
		map.put("rata", "2");
		map.put("broj", "3");
		map.put("iznos", "33000");
		map.put("rok", "1.5.2013");

		
		mySchList.add(map);
		
		mScholarshipAdapter = new SimpleAdapter(getActivity(), mySchList, R.layout.schshp_list_item, new String[]{"skgod", "god","status","nacin",
					"profil","rata","broj","iznos","rok"},new int[]{R.id.schship_year, R.id.schship_study_year, R.id.schship_status,R.id.schship_method,
						R.id.schship_profile,R.id.schship_installment, R.id.schship_inst_number,R.id.schship_amount,R.id.schship_deadline});
		mSchoolarshipList.setAdapter(mScholarshipAdapter);
		
		ArrayList<HashMap<String, String>> myAcclist = new ArrayList<HashMap<String, String>>();
		
		map.put("trenutak","2.3.2013 14:32");
		map.put("opis", "Pocetno stanje na racunu kreiranje pocetnog stanja na racunu");
		map.put("uplata", "0.00");
		map.put("ispata", "");
		map.put("stanje","0.00");
		
		myAcclist.add(map);
		
		mAccountAdapter = new SimpleAdapter(getActivity(), myAcclist, R.layout.account_list_item, new String[]{"trenutak", "opis","uplata","isplata",
					"stanje"},new int[]{R.id.account_change_time, R.id.account_detail, R.id.account_in,R.id.account_out,
						R.id.account_state});
		mAccountList.setAdapter(mAccountAdapter);
	}

}
